package org.forum.utils;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class JsonUtil {
	Logger logger = LoggerFactory.getLogger(JsonUtil.class);

	public void outToJsonString(String jsonString){
		HttpServletResponse response = ServletActionContext.getResponse();
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/json;charset=utf-8");
		try {
			response.getWriter().write(jsonString);
			response.getWriter().flush();
			response.getWriter().close();
			logger.debug("outToJsonString()成功执行！");
		} catch (IOException e) {
			if(logger.isDebugEnabled()){
				logger.debug("Json取得Writer是出错：" + "\n" +  e.getMessage());
			}
		}
		
	}
	
}
